/**
 * @class   wosh::Response
 * @brief   Responses are related to Requests.
 *          Almost all Requests are replied with a wosh::Response Object
 *          It holds the reference method and a generic Data as content.
 *          
 *          
 *
 ****************************************************************************
 * @version 0.8.499 $Id: Response.h 2831 2010-08-02 22:15:14Z alex $
 * @author  Alessandro Polo
 ****************************************************************************/
/* Copyright (c) 2007-2010, WOSH - Wide Open Smart Home 
 * by Alessandro Polo - OpenSmartHome.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the OpenSmartHome.com WOSH nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY Alessandro Polo ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL Alessandro Polo BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ****************************************************************************/

#ifndef __WOSH_Core_Response_H__
 #define __WOSH_Core_Response_H__

 #include <woshDefs.h>
 #include <core/MessageContentGeneric.h>


namespace wosh {

class Response : public MessageContentGeneric
 {
	WOSH_SERIALIZABLE(wosh::Response)
	WOSH_COMPARE_RTTI(wosh::Response)

	public:
		/**
		 * @brief  Empty constructor.
		 */
		Response();
		/**
		 * @brief  Constructor with initializer(s), provided for convenience.
		 * @param [in] method the method name to be executed
		 * @param [in] ReturnValue the returned value of the call
		 * @param [in] data the data object (ISerializable abstraction) associated with the response. May be NULL.
		 */
		explicit Response( const std::string& method, ISerializable* data = NULL, WRESULT ReturnValue = WRET_OK );
		/**
		 * @brief  Copy constructor.
		 * @param m [in] the source object to be copied
		 */
		Response( const Response& m );
		/**
		 * @brief  Empty destructor.
		 */
		virtual ~Response() { }

/** @name Getters
 * @{
 ******************************************************************************/
	public:
		/**
		 * @brief  Get the method (name) associated with the request
		 * @return returns constant STL string reference (to internal field)
		 */
		inline const std::string& getMethod() const					{ return this->contentContext; }

		/**
		 * @brief  Get the return value associated with the response
		 * @return returns the return value as WRESULT
		 */
		inline WRESULT getReturnValue() const 						{ return this->returnValue; }

		/**
		 * @brief  Get MessageContent::TYPE of this implementation: a RESPONSE
		 * @return returns MessageContent::RESPONSE
		 */
		virtual MessageContent::TYPE getType() const				{ return MessageContent::RESPONSE; }
//@}
/** @name Setters
 * @{
 ******************************************************************************/
	public:
		/**
		 * @brief  Set the method (name) associated with the request
		 * @param [in] value the method string to be assigned
		 * @see    setContentContext()
		 */
		void setMethod( const std::string& value ) 					{ this->contentContext = value; }

		/**
		 * @brief  Set the return value associated with the response
		 * @param [in] value the return value associated with the response
		 */
		void setReturnValue( WRESULT value ) 						{ this->returnValue = value; }
//@}
/** @name Operators Overloading
 * @{
 ******************************************************************************/
	public:
		virtual Response& operator=(const Response& m);
		virtual bool operator==(const Response &other) const;
		virtual bool operator!=(const Response &other) const		{ return !(*this == other);  }
//@}
/** @name Internal methods
 * @{
 ******************************************************************************/
	protected:
		virtual void clear();
//@}
/** @name Internal vars
 * @{
 ******************************************************************************/
	protected:
		WRESULT returnValue;		///< the return value associated with the response
//@}

}; // class def


}; // namespace wosh

#endif //__WOSH_Core_Response_H__
